<?php
/**
 * @filesource:					DepositAction.class.php
 * @desc:						寄存人管理模块
 * 
 * @author:						shenyaqing
 * @copyright:					hou.yining@gmail.com
 * @date:						2011-04-20
 */
class DepositAction extends CommonDeadAction{
	public function index(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('deposit_manage'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/add', 'title' => L('add_deposit')),
		);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
		$dead = new DeadModel();
		$type_id = $_REQUEST['id'];
		
		$list = $dead->getDeadInfo($type_id);
		$this->assign('list', $list['rs']);
		$this->assign('page', $list['show']);
		
		$this->display();
	}
	public function add(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('deposit_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/add/', 'title' => L('add_deposit'), 'sort' => C('CRUMB_LAST')),
		);
		
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index/id/1', 'title' => L('list_deposit')),
			);
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
		$graveyard = new GraveyardModel();
		$result = $graveyard->where()->select();
		$this->assign('result',$result);
		
		$GeneralCustomer = new GeneralCustomerModel();
		$rr = $GeneralCustomer->where("type_id=4")->select();
		
		$name = $_REQUEST['name'];
		$id = $_REQUEST['id'];
		$this->assign('name',$name);
		$this->assign('id',$id);
		
		$omit = D('region');
		$province = $omit->where("level=1")->select();
		$this->assign('province',$province);
		
		$this->assign('rr',$rr);
		$this->assign('operator',$_SESSION['loginUserName']);
		parent::add();
	}
	public function edit(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('deposit_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/edit/id/' . $_REQUEST['id'], 'title' => L('edit_deposit'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index/id/1', 'title' => L('list_deposit')),
			);
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
		$model = new DeadModel();
		$id = $_REQUEST [$model->getPk ()];
		$vo = $model->getDieInfo($id);
		$this->assign ( 'list', $vo );
		
		$obj =  new GeneralCustomerModel();
		$result = $obj->where('type_id=4')->select();
		$this->assign ( 'rr', $result );
		
		$mo =  D( 'graveyard' );
		$res = $mo->select();
		$this->assign ( 'result', $res );
		$this->assign('operator',$_SESSION['loginUserName']);
		
		$omit = D('region');
		$province = $omit->where("level=1")->select();
		$this->assign('province',$province);
		$this->display ();
	}
	public function all_delete(){
    	parent::all_delete();
		echo "<script>alert('已全部删除！');window.location.href('".ROOT_PATH."Deposit/index/id/1');</script>";
    }
	public function search(){
		$model = new DeadModel();
		$where = $_POST['name'];
		$result = $model->getDieInfo2($where);
		$this->assign('list',$result);
		$this->display('index');
	}
	public function selectLocation(){
		$place = new PlaceDistrictModel();
		$sections = $place->where("level=2")->select();
		$this->assign('sections',$sections);
		$this->display();	
	}
	//查询排
	public function selectrows(){
		
		$pid = $_GET['qu'];
		$place = new PlaceDistrictModel();
		$rows = $place->where("pid='$pid'")->select();
		exit(json_encode($rows));
		
	}
	
    //查询号
	public function selectnumbers(){
		
		$pid = $_GET['pai'];
		$place = new HoldPlaceModel();
		$number = $place->where("district_id='$pid'")->select();
		exit(json_encode($number));
		
	}
	//加载选择主办人页面
	public function selectEntre(){
		$this->display();
	}
	//搜索主办人
	public function searEntre(){
		if(!empty($_POST['name'])){
			$where['name'] = $_POST['name'];
		}
		if(!empty($_POST['age'])){
			$where['age'] = $_POST['age'];
		}
		if(!empty($_POST['address'])){
			$where['address'] = $_POST['address'];
		}
		$obj = D('general_customer');
		$a = $obj->where($where)->select();
		$this->assign('vo',$a);
		$this->display('selectEntre');
	}
	public function seeLocation(){
		//dump($_POST);
	}

}
?>